#include <stdio.h>
#include <string.h>

int lengthOfLongestSubstring(char* s) {
    int len = strlen(s);
    int visited[128]; // 存储字符是否出现过的标志数组
    memset(visited, -1, sizeof(visited));
    int maxLen = 0;
    int start = 0;
    
    for (int i = 0; i < len; i++) {
        if (visited[s[i]] >= start) {
            start = visited[s[i]] + 1;
        }
        visited[s[i]] = i;
        int currentLen = i - start + 1;
        if (currentLen > maxLen) {
            maxLen = currentLen;
        }
    }
    
    return maxLen;
}

int main() {
    char s[128];
    printf("Please input the string\n");
    scanf("%s", s);
    int result = lengthOfLongestSubstring(s);
    printf("values are %d\n", result);
    
    return 0;
}
